package com.relytosoft.mizar.media.analyze.api.pojo.dto;

import com.relytosoft.dubhe.common.core.utils.BeanCopyUtils;
import com.relytosoft.mizar.media.analyze.api.entity.face.AyFaceTask;
import com.relytosoft.mizar.media.analyze.api.pojo.vo.AyCameraVo;
import com.relytosoft.mizar.media.common.enums.DeleteStatusEnum;
import com.relytosoft.mizar.media.common.enums.TaskStatusEnum;
import com.relytosoft.mizar.media.common.enums.TaskTypeEnum;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;

import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

/**
 * @Author: zyc
 * @version: v1.0
 * @description: com.relytosoft.mizar.analyze.face.api.pojo.dto
 * @Date: 2022/5/13 9:58
 */
@ApiModel("AyFaceTaskDto")
public class AyFaceTaskDto implements Serializable {

    private static final long serialVersionUID = 2047627886976782831L;


    /**
     * 任务名称
     */
    @ApiModelProperty(value = "任务名称", required = true)
    @NotBlank(message = "任务名称不能为空")
    private String name;

    /**
     * 任务类型;1：实时任务，2：离线视频任务，3：离线文件任务
     */
    @ApiModelProperty(value = "任务类型;1：实时任务，2：离线视频任务，3：离线文件任务")
    private Integer type;

    /**
     * 设备
     */
    @ApiModelProperty(value = "设备", required = true)
    @NotNull(message = "设备不能为空")
    private List<AyCameraVo> ayCameraVos;



    /**
     * 状态 -1-未启动，0-启动
     */
    @ApiModelProperty(value = "状态;-1-未启动，0-启动", required = true)
    @NotNull(message = "状态不能为空")
    private Integer status;


    /**
     * 备注
     */
    @ApiModelProperty(value = "备注")
    private String remark;


    /**
     * 获得任务名称
     */
    public String getName(){
        return this.name;
    }
    /**
     * 设置任务名称
     */
    public void setName(String name){
        this.name = name;
    }



    /**
     * 获得任务类型;1：实时任务，2：离线视频任务，3：离线文件任务
     */
    public Integer getType(){
        return this.type;
    }
    /**
     * 设置任务类型;1：实时任务，2：离线视频任务，3：离线文件任务
     */
    public void setType(Integer type){
        this.type = type;
    }

    /**
     * 获得状态 :正在运行 ：已停止 ：已删除
     */
    public Integer getStatus(){
        return this.status;
    }
    /**
     * 设置状态 :正在运行 ：已停止 ：已删除
     */
    public void setStatus(Integer status){
        this.status = status;
    }


    /**
     * 获得设备
     */
    public List<AyCameraVo> getAyCameraVos() {
        return this.ayCameraVos;
    }

    /**
     * 设置设备
     */
    public void setAyCameraVos(List<AyCameraVo> ayCameraVos) {
        this.ayCameraVos = ayCameraVos;
    }


    /**
     * 获得备注
     */
    public String getRemark(){
        return this.remark;
    }
    /**
     * 设置备注
     */
    public void setRemark(String remark){
        this.remark = remark;
    }

    @Override
    public String toString() {
        return "AyStructureTaskDto{" +
                "name='" + name + '\'' +
                ", type=" + type +
                ", ayCameraVos=" + ayCameraVos +
                ", status=" + status +
                ", remark='" + remark + '\'' +
                '}';
    }

    public static AyFaceTask buildAddTask(AyFaceTaskDto ayFaceTaskDto) {
        AyFaceTask ayFaceTask = new AyFaceTask();
        BeanCopyUtils.copy(ayFaceTaskDto, ayFaceTask);
        ayFaceTask.setType(TaskTypeEnum.REAL_TIME.getValue());
        ayFaceTask.setIsDeleted(DeleteStatusEnum.NOT_DELETED.getValue());
        if(ayFaceTask.getStatus()== TaskStatusEnum.CREATED.getValue()){
            ayFaceTask.setBeginTime(LocalDateTime.now());
        }
        return ayFaceTask;
    }
}
